home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1993 July / InfoMagic USENET CD-ROM July 1993.ISO / sources / misc / volume6 / shadow-2 < prev    next >
Encoding:
Internet Message Format  |  1989-02-03  |  18.0 KB

  1. Path: xanth!nic.MR.NET!csd4.milw.wisc.edu!leah!itsgw!steinmetz!uunet!allbery
  2. From: allbery@uunet.UU.NET (Brandon S. Allbery - comp.sources.misc)
  3. Newsgroups: comp.sources.misc
  4. Subject: v06i022: shadow password files, replacement login(1) and passwd(1)
  5. Message-ID: <47754@uunet.UU.NET>
  6. Date: 29 Jan 89 21:10:53 GMT
  7. Sender: allbery@uunet.UU.NET
  8. Reply-To: jfh@convex.UUCP (John F. Haugh II)
  9. Lines: 622
  10. Approved: allbery@uunet.UU.NET (Brandon S. Allbery - comp.sources.misc)
  11. X-Arch-Keywords: portable, c, login, passwd, su, sulogin, shadow
  12.  
  13. Posting-number: Volume 6, Issue 22
  14. Submitted-by: jfh@convex.UUCP (John F. Haugh II)
  15. Archive-name: shadow-2
  16.  
  17. [I haven't the faintest idea what the reply addresses to these things will
  18. look like.  Back to the drawing board!  ++bsa]
  19.  
  20. #! /bin/sh
  21. # This is a shell archive, meaning:
  22. # 1. Remove everything above the #! /bin/sh line.
  23. # 2. Save the resulting text in a file.
  24. # 3. Execute the file with /bin/sh (not csh) to create:
  25. #    login.1
  26. #    passwd.1
  27. #    passwd.4
  28. #    shadow.3
  29. #    shadow.4
  30. #    su.1
  31. #    sulogin.8
  32. #    pwconv.8
  33. #    pwunconv.8
  34. # This archive created: Tue Jan 17 19:31:52 1989
  35. # By:    John F. Haugh II (River Parishes Programming, Dallas TX)
  36. export PATH; PATH=/bin:/usr/bin:$PATH
  37. if test -f 'login.1'
  38. then
  39.     echo shar: "will not over-write existing file 'login.1'"
  40. else
  41. cat << \SHAR_EOF > 'login.1'
  42. .TH LOGIN 1
  43. .SH NAME
  44. login \- Begin session on the system
  45. .SH SYNOPSIS
  46. .B login
  47. [ username [ environmental-variables ] ]
  48. .SH DESCRIPTION
  49. .I login
  50. is used to establish a new session with the system.
  51. It is normally invoked automatically by responding to the
  52. .B login:
  53. prompt on the user\'s terminal.
  54. .I login
  55. may be special to the shell and may not be invoked as a sub-process.
  56. Typically,
  57. .I login
  58. is treated by the shell as \fBexec login\fR which causes the user
  59. to exit from the current shell.
  60. Attempting to execute \fIlogin\fR from any shell but the login shell
  61. will produce an error message.
  62. .PP
  63. When invoked from the \fBlogin:\fR prompt, the user may enter
  64. environmental variables after the username.
  65. These variables are entered in the form \fBNAME=VALUE\fR.
  66. Not all variables may be set in the fashion, notably \fBPATH\fR,
  67. \fBHOME\fR and \fBSHELL\fR.
  68. Additionally, \fBIFS\fR may be inhibited if the user\'s login
  69. shell is \fB/bin/sh\fR.
  70. .PP
  71. The user is then prompted for a password, where appropriate.
  72. Echoing is disabled to prevent revealing the password.
  73. Only a small number of password failures are permitted before
  74. \fIlogin\fR exits and the communications link is severed.
  75. .PP
  76. If password aging has been enabled for your account, you may be
  77. prompted for a new password before proceeding.
  78. You will be forced to provide your old password and the new
  79. password before continuing.
  80. Please refer to \fIpasswd(1)\fR for more information.
  81. .PP
  82. After a successful login,
  83. you will be informed of any system messages and the presence
  84. of mail.
  85. You may turn off the printing of the system message file,
  86. \fI/etc/motd\fR, by creating a zero-length file \fI.hushlogin\fR
  87. in your login directory.
  88. The mail message will be one of "\fIYou have new mail.\fR",
  89. "\fIYou have mail.\fR", or "\fINo Mail.\fR" according to
  90. the condition of your mailbox.
  91. .PP
  92. Your user and group ID will be set according to their values in
  93. the \fI/etc/passwd\fR file.
  94. The value for \fB$HOME\fR, \fB$SHELL\fR, \fB$PATH\fR, \fB$LOGNAME\fR,
  95. and \fB$MAIL\fR are set according to the appropriate fields in the
  96. password entry.
  97. Ulimit, umask and nice values may also be set according to
  98. entries in the GECOS field.
  99. .PP
  100. An initialization script for your command interpreter may also be
  101. executed.
  102. Please see the appropriate manual section for more information on
  103. this function.
  104. .SH CAVEATS
  105. .PP
  106. This version of \fIlogin\fR has many compilation options, only some of which
  107. may be in use at any particular site.
  108. .SH Files
  109. /etc/utmp \- list of current login sessions
  110. .br
  111. /etc/wtmp \- list of previous login sessions
  112. .br
  113. /etc/passwd \- user account information
  114. .br
  115. /etc/shadow \- encrypted passwords and age information
  116. .br
  117. /etc/motd \- system message file
  118. .br
  119. $HOME/.profile \- initialization script for default shell
  120. .br
  121. $HOME/.hushlogin \- suppress printing of system messages
  122. .br
  123. .SH See Also
  124. .PP
  125. getty(1M),
  126. mail(1),
  127. passwd(1),
  128. sh(1),
  129. su(1),
  130. d_passwd(4),
  131. passwd(4)
  132. SHAR_EOF
  133. fi
  134. if test -f 'passwd.1'
  135. then
  136.     echo shar: "will not over-write existing file 'passwd.1'"
  137. else
  138. cat << \SHAR_EOF > 'passwd.1'
  139. .TH PASSWD 1
  140. .SH NAME
  141. passwd \- change user password
  142. .SH SYNOPSIS
  143. \fBpasswd\fR [ \fB-f\fR ] [ \fIname\fR ]
  144. .SH DESCRIPTION
  145. \fIpasswd\f changes passwords for user accounts.
  146. A normal user may only change the password for their own account,
  147. the super user may change the password for any account.
  148. .PP
  149. The user is first prompted for their old password,
  150. if one is present.
  151. This password is then encrypted and compared against the
  152. stored password.
  153. The user has only one chance to enter the correct password.
  154. The super user is permitted to bypass this step so that forgotten
  155. passwords may be changed.
  156. .PP
  157. After the password has been entered password aging information
  158. is checked to see if the user is permitted to change their password
  159. at this time.
  160. If not, \fIpasswd\fR refuses to change the password and exits.
  161. .PP
  162. The user is then prompted for a replacement password.
  163. This password is tested for complexity.
  164. As a general guideline,
  165. passwords should consist of 6 to 8 characters including
  166. one or more from each of following sets:
  167. .IP "" .5i
  168. Lower case alphabetics
  169. .IP "" .5i
  170. Upper case alphabetics
  171. .IP "" .5i
  172. Digits 0 thru 9
  173. .IP "" .5i
  174. Punctuation marks
  175. .PP
  176. Care must be taken not to include the system default erase
  177. or kill characters.
  178. \fIpasswd\fR will reject any password which is not suitably
  179. complex.
  180. .PP
  181. If the password is accepted,
  182. \fIpasswd\fR will prompt again and compare the second entry
  183. against the first.
  184. Both entries are require to match in order for the password
  185. to be changed.
  186. .SH Hints
  187. The security of a password depends upon the strength of the
  188. encryption algorithm and the size of the key space.
  189. The \fB\s-2UNIX\s+2\fR System encryption method is based on
  190. the NBS DES algorithm and is very secure.
  191. .PP
  192. Compromises in password security normally result from careless
  193. password selection or handling.
  194. For this reason, you should select a password which does not
  195. appear in a dictionary or which must be written down.
  196. The password should also not be a proper name, your license
  197. number, birth date, or street address.
  198. Any of these may be used as guesses to violate system security.
  199. .PP
  200. Your password must easily remembered so that you will not
  201. be forced to write it on a piece of paper.
  202. This can be accomplished by appending two small words together
  203. and separating each with a special character or digit.
  204. For example, Pass%word.
  205. .PP
  206. Other methods of construction involve selecting an easily
  207. remembered phrase from literature and selecting the first
  208. or last letter from each.
  209. An example of this is
  210. .IP "" .5i
  211. Ask not for whom the bell tolls.
  212. .PP
  213. which produces
  214. .IP "" .5i
  215. An4wtbt.
  216. .PP
  217. You may be reasonably sure few crackers will have
  218. included this in their dictionary.
  219. .SH CAVEATS
  220. Not all options may be supported.
  221. Password complexity checking may vary from site to site.
  222. The user is urged to select as complex a password as they
  223. feel comfortable with.
  224. A \fB-f\fR option exists to permit the superuser to override
  225. any password complexity testing,
  226. normal users must create passwords which pass the complexity
  227. test.
  228. .SH Files
  229. /etc/passwd \- user account information
  230. .br
  231. /etc/shadow \- encrypted user passwords
  232. .SH See Also
  233. passwd(3),
  234. passwd(4)
  235. SHAR_EOF
  236. fi
  237. if test -f 'passwd.4'
  238. then
  239.     echo shar: "will not over-write existing file 'passwd.4'"
  240. else
  241. cat << \SHAR_EOF > 'passwd.4'
  242. .TH PASSWD 4
  243. .SH NAME
  244. passwd \- The password file
  245. .SH DESCRIPTION
  246. .I passwd
  247. contains various pieces of information for each user account.
  248. Included is
  249. .IP "" .5i
  250. Login name
  251. .IP "" .5i
  252. Optional encrypted password
  253. .IP "" .5i
  254. Numerical user ID
  255. .IP "" .5i
  256. Numerical group ID
  257. .IP "" .5i
  258. User name or comment field
  259. .IP "" .5i
  260. User home directory
  261. .IP "" .5i
  262. User command interpreter
  263. .PP
  264. The password field may not be filled if shadow passwords
  265. have been enabled.
  266. If shadow passwords are being used, the encrypted password will
  267. be found in \fB/etc/shadow\fR.
  268. The encryped password consists of 13 characters from the
  269. 64 character alphabet
  270. a thru z, A thru Z, 0 thru 9, \. and /.
  271. Refer to \fIcrypt(3)\fR for details on how this string is
  272. interpreted.
  273. .PP
  274. An optional password age string may follow the encrypted
  275. password, separated by a comma, from the same alphabet
  276. as the password itself.
  277. The first character gives the number of weeks during which the
  278. password is valid.
  279. The second character gives the number of weeks which must pass
  280. before the user is permitted to change the password.
  281. The last two characters give the week since Jan 1970 when the
  282. password was last changed.
  283. When the number of weeks during which the password is valid
  284. have passed, the user will be required to provide a new
  285. password.
  286. .PP
  287. The comment field is used by various system utilities, such as
  288. \fIfinger(1)\fR.
  289. Three additional values may be present in the comment field.
  290. They are
  291. .IP "" .5i
  292. pri= \- set initial value of nice
  293. .IP "" .5i
  294. umask= \- set initial value of umask
  295. .IP "" .5i
  296. ulimit= \- set initial value of ulimit
  297. .PP
  298. These fields are separated from each other and from any other
  299. comment field by a comma.
  300. .PP
  301. The home directory field provides the name of the initial
  302. working directory.
  303. \fILogin\fR uses this information to set the value of
  304. the \fBHOME\fR environmental variable.
  305. .PP
  306. The command interpreter field provides the name of the user's
  307. command language interpreter, or the name of the initial program
  308. to execute.
  309. \fILogin\fR uses this information to set the value of the
  310. \fBSHELL\fR environmental variable.
  311. If this field is empty, it defaults to the value \fB/bin/sh\fR.
  312. .SH Files
  313. /etc/passwd \- user account information
  314. .SH See Also
  315. login(1),
  316. passwd(1),
  317. su(1),
  318. sulogin(1M),
  319. shadow(4),
  320. pwconv(8),
  321. pwunconv(8)
  322. SHAR_EOF
  323. fi
  324. if test -f 'shadow.3'
  325. then
  326.     echo shar: "will not over-write existing file 'shadow.3'"
  327. else
  328. cat << \SHAR_EOF > 'shadow.3'
  329. .TH SHADOW 3
  330. .SH NAME
  331. shadow \- encrypted password file routines
  332. .SH Syntax
  333. .IP "" .5i
  334. #include <shadow.h>
  335. .IP "" .5i
  336. struct spwd *getspent();
  337. .br
  338. struct spwd *getspnam(char * name);
  339. .br
  340. void setspent();
  341. .br
  342. void endspent();
  343. .br
  344. struct spwd *fgetspent(FILE *fp);
  345. .br
  346. int putspent(struct spwd *p,FILE *fp);
  347. .SH DESCRIPTION
  348. .I shadow
  349. manipulates the contents of the shadow password file,
  350. \fB/etc/shadow\fR.
  351. The structure in the \fI#include\fR file is
  352. .IP "" .5i
  353. struct spwd {
  354. .br
  355.     char    *sp_namp; /* user login name */
  356. .br
  357.     char    *sp_pwdp; /* encrypted password */
  358. .br
  359.     long    sp_lstchg; /* last password change */
  360. .br
  361.     int    sp_max; /* days before change required */
  362. .br
  363.     int    sp_min; /* days until change allowed. */
  364. .br
  365. }
  366. .PP
  367. The meanings of each field are
  368. .IP "" .5i
  369. sp_namp \- pointer to null-terminated user name.
  370. .IP "" .5i
  371. sp_pwdp \- pointer to null-terminated password.
  372. .IP "" .5i
  373. sp_lstchg \- days since Jan 1, 1970 password was last changed.
  374. .IP "" .5i
  375. sp_max \- days after which password must be changed
  376. .IP "" .5i
  377. sp_min \- days before which password may not be changed.
  378. .SH Description
  379. \fIgetspent\fR, \fIgetspname\fR, and \fIfgetspent\fR each return
  380. a pointer to a \fBstruct spent\fR.
  381. \fIgetspent\fR returns the
  382. next entry from the file, and \fIfgetspent\fR returns the next
  383. entry from the given stream, which is assumed to be a file of
  384. the proper format.
  385. \fIgetspnam\fR searches from the current position in the file for
  386. an entry matching \fIname\fR.
  387. .PP
  388. \fIsetspent\fR and \fIendspent\fR may be used to begin and end,
  389. respectively, access to the shadow password file.
  390. .SH Diagnostics
  391. Routines return NULL if no more entries are available or if an
  392. error occurs during processing.
  393. .SH Caveats
  394. These routines may only be used by the super user as access to
  395. the shadow password file is restricted.
  396. .SH Files
  397. /etc/shadow \- encrypted user passwords
  398. .SH See Also
  399. getpwent(3),
  400. shadow(4)
  401. SHAR_EOF
  402. fi
  403. if test -f 'shadow.4'
  404. then
  405.     echo shar: "will not over-write existing file 'shadow.4'"
  406. else
  407. cat << \SHAR_EOF > 'shadow.4'
  408. .TH SHADOW 4
  409. .SH NAME
  410. shadow \- encrypted password file
  411. .SH DESCRIPTION
  412. .I shadow
  413. contains the encrypted password information for user's accounts
  414. and optional the password aging information.
  415. Included is
  416. .IP "" .5i
  417. Login name
  418. .IP "" .5i
  419. Encrypted password
  420. .IP "" .5i
  421. Date password last changed
  422. .IP "" .5i
  423. Days before password may be changed
  424. .IP "" .5i
  425. Days after which password must be changed
  426. .PP
  427. The password field must be filled.
  428. The encryped password consists of 13 characters from the
  429. 64 character alphabet
  430. a thru z, A thru Z, 0 thru 9, \. and /.
  431. Refer to \fIcrypt(3)\fR for details on how this string is
  432. interpreted.
  433. .PP
  434. The date of the last password change is given as the number
  435. of days since Jan 1, 1970.
  436. The password may not be changed again until the proper number
  437. of days have passed, and must be changed after the maximum
  438. number of days.
  439. If the minimum number of days required is greater than the
  440. maximum number of day allowed, this password may not be
  441. changed by the user.
  442. .PP
  443. This information supercedes any password or password age
  444. information present in \fB/etc/passwd\fR.
  445. .PP
  446. This file must not be readable by regular users if password
  447. security is to be maintained.
  448. .SH Files
  449. /etc/passwd \- user account information
  450. .br
  451. /etc/shadow \- encrypted user passwords
  452. .SH See Also
  453. login(1),
  454. passwd(1),
  455. su(1),
  456. sulogin(1M),
  457. passwd(4),
  458. pwconv(8),
  459. pwunconv(8)
  460. SHAR_EOF
  461. fi
  462. if test -f 'su.1'
  463. then
  464.     echo shar: "will not over-write existing file 'su.1'"
  465. else
  466. cat << \SHAR_EOF > 'su.1'
  467. .TH SU 1
  468. .SH NAME
  469. su \- Change user ID or become super-user
  470. .SH SYNOPSIS
  471. .B su
  472. [ - ] [ username [ args ] ]
  473. .SH DESCRIPTION
  474. .I su
  475. is used to become another user during a login session.
  476. Invoked without a username, \fIsu\fR defaults to becoming
  477. the super user.
  478. The optional argument \fB\-\fR may be used to provide an
  479. environment similiar to what the user would expect had
  480. the user logged in directly.
  481. .PP
  482. Additional arguments may be provided after the username,
  483. in which case they are supplied to the user\'s login shell.
  484. In particular, an argument of \fB-c\fR will cause the
  485. next argument to be treated as a command by most command
  486. interpreters.
  487. .PP
  488. The user will be prompted for a password, if appropriate.
  489. Invalid passwords will produce an error message.
  490. All attempts, both valid and invalid, are logged to detect
  491. abuses of the system.
  492. .PP
  493. The current environment is passed to the new shell.
  494. The value of \fB$PATH\fR is reset to \fB/bin:/usr/bin\fR
  495. for normal users, or \fB/bin:/usr/bin:/etc\fR for the super user.
  496. .SH CAVEATS
  497. .PP
  498. This version of \fIsu\fR has many compilation options, only some of which
  499. may be in use at any particular site.
  500. .SH Files
  501. /etc/passwd \- user account information
  502. .br
  503. /etc/shadow \- encrypted passwords and age information
  504. .br
  505. $HOME/.profile \- initialization script for default shell
  506. .SH See Also
  507. login(1),
  508. sh(1)
  509. SHAR_EOF
  510. fi
  511. if test -f 'sulogin.8'
  512. then
  513.     echo shar: "will not over-write existing file 'sulogin.8'"
  514. else
  515. cat << \SHAR_EOF > 'sulogin.8'
  516. .TH SULOGIN 8
  517. .SH NAME
  518. sulogin \- Single-user login
  519. .SH DESCRIPTION
  520. .I sulogin
  521. is invoked by \fB/etc/init\fR prior to allowing the user
  522. access to the system when in single user mode.
  523. This feature may only be available on certain systems where
  524. \fIinit\fR has been modified accordingly, or where the
  525. \fB/etc/inittab\fR has an entry for a single user login.
  526. .PP
  527. The user is prompted
  528. .IP "" .5i
  529. Type control-d for normal startup,
  530. .br
  531. (or give root password for system maintenance):
  532. .PP
  533. If the user enters the correct root password, a login session
  534. is initiated.
  535. When \fBEOF\fR is pressed instead, the system enters multi-user
  536. mode.
  537. .PP
  538. After the user exits the single-user shell, or presses \fBEOF\fR,
  539. the system begins the initialization process required to enter
  540. multi-user mode.
  541. .SH CAVEATS
  542. .PP
  543. This command can only be used if \fIinit\fR has been modified to call
  544. \fB/etc/sulogin\fR instead of \fB/bin/sh\fR,
  545. or if the user has set the \fIinittab\fR to support a single user
  546. login.
  547. .PP
  548. As complete an environment as possible is created.
  549. However, various devices may be unmounted or uninitialized and many 
  550. of the user commands may be unavailable or nonfunctional as a result.
  551. .SH Files
  552. /etc/passwd \- user account information
  553. .br
  554. /etc/shadow \- encrypted passwords and age information
  555. .br
  556. /.profile \- initialization script for single user shell
  557. .SH See Also
  558. login(1),
  559. init(1M),
  560. sh(1)
  561. SHAR_EOF
  562. fi
  563. if test -f 'pwconv.8'
  564. then
  565.     echo shar: "will not over-write existing file 'pwconv.8'"
  566. else
  567. cat << \SHAR_EOF > 'pwconv.8'
  568. .TH PWCONV 8
  569. .SH NAME
  570. pwconv \- convert and update shadow password files
  571. .SH SYNOPSIS
  572. /etc/pwconv
  573. .SH DESCRIPTION
  574. \fIPwconv\fR copies the old password file information to a new shadow
  575. password file,
  576. merging entries from an optional existing shadow file.
  577. The new password file is left in \fBnpasswd\fR,
  578. the new shadow file is left in \fBnshadow\fR.
  579. Both of these are files are created with modes which only permit
  580. read access to the owner.
  581. Existing shadow entries are copied as is.
  582. New entries are created with passwords which expire in 10000 days,
  583. with a last changed date of today,
  584. unless password aging information was already present.
  585. Entries with blank passwords are not copied to the shadow file at all.
  586. .SH Files
  587. /etc/passwd \- old encrypted passwords and password aging
  588. .br
  589. /etc/shadow \- previously converted shadow password file
  590. .br
  591. ./npasswd \- new password file
  592. .br
  593. ./nshadow \- new shadow password file
  594. .SH See Also
  595. passwd(1),
  596. passwd(4),
  597. shadow(4),
  598. pwunconv(8)
  599. SHAR_EOF
  600. fi
  601. if test -f 'pwunconv.8'
  602. then
  603.     echo shar: "will not over-write existing file 'pwunconv.8'"
  604. else
  605. cat << \SHAR_EOF > 'pwunconv.8'
  606. .TH PWUNCONV 8
  607. .SH NAME
  608. pwunconv \- restore old password file from shadow password file
  609. .SH SYNOPSIS
  610. /etc/pwunconv
  611. .SH DESCRIPTION
  612. \fIPwunconv\fR copies the password file information from the shadow
  613. password file,
  614. merging entries from an optional existing shadow file.
  615. The new password file is left in \fBnpasswd\fR.
  616. This file is created with modes which allow read access for
  617. the owner only.
  618. There is no new shadow file.
  619. Password aging information is translated where possible.
  620. .SH Files
  621. /etc/passwd \- old encrypted passwords and password aging
  622. .br
  623. /etc/shadow \- previously converted shadow password file
  624. .br
  625. ./npasswd \- new password file
  626. .SH See Also
  627. passwd(1),
  628. passwd(4),
  629. shadow(4),
  630. pwconv(8)
  631. SHAR_EOF
  632. fi
  633. exit 0
  634. #    End of shell archive
  635.